<?php

namespace App\Http\Controllers\Admin;

use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Controllers\Controller;
use App\Repositories\BannerRepo;
class BannerController extends BaseController
{
    protected $bannerRepo;

    public function _initialize()
    {
        $this->bannerRepo = new BannerRepo();
    }
    public function all()
    {
        $data = $this->bannerRepo->getAll();
        return $this->sucRes(200,$data); 
    }
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        //
        $data = $this->bannerRepo->getBannerList();
        return $this->sucRes(200,$data);
    }

    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create(Request $request)
    {
        $input = $request->only(['title','link','url','status','background']);
        $this->bannerRepo->addBanner($input);
        return $this->sucRes(200);
    }

    public function edit(Request $request)
    {
        $input = $request->only(['title','link','url','status','background']);
        $id    = $request->id;
        $this->bannerRepo->editBanner($id,$input);
        return $this->sucRes(200);
    }
    public function del(Request $request)
    {
        $id    = $request->id;
        $bannerRepo = new BannerRepo();
        $bannerRepo->delBanner($id);
        return $this->sucRes(200);
    }
}